package com.pitop.base.interceptor;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.annotation.Resource;

/**
 * Created by lixin on 2018/6/23.
 */
@SpringBootConfiguration
public class ContextConfiguration extends WebMvcConfigurerAdapter {

    @Resource
    private ContextInterceptor contextInterceptor;
    @Resource
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(contextInterceptor)
                .excludePathPatterns("/swagger-resources/**", "/error")
                .addPathPatterns("/**");//全局拦截器
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/syncFactoryData/**", "/syncNewData/**")
                .excludePathPatterns("/swagger-resources/**", "/error", "/factory/token/**");
    }
}
